#!/usr/bin/env node

const cp = require('child_process');

console.log('I am father process.pid',process.pid);

const son = cp.fork('./11-ipc-child.js'),
  dau = cp.fork('./11-ipc-child.js');

son.on('message',(msg)=>{
  console.log(`I have a son ${msg}`);
});
dau.on('message',(msg)=>{
  console.log(`I have a daughter ${msg}`);
});
//son.send('work hard');
//dau.send('good study');

setTimeout(()=>{
  son.send('2 seconds son');
},2000);
setTimeout(()=>{
  dau.send('4 seconds dau');
},4000);

setTimeout(()=>{
  son.kill('SIGINT');
  dau.kill('SIGINT');
},6000);

